import { DataSource, DataSourceOptions } from "typeorm";
import envConfig from "./env.config";
import * as Entitys from "../entity";
import * as Subscribers from "src/subscriber";

export const ormConfig: DataSourceOptions = {
    type: envConfig["DB_TYPE"] as any,
    host: envConfig["DB_HOST"],
    port: Number(envConfig["DB_PORT"]),
    username: envConfig["DB_USERNAME"],
    password: envConfig["DB_PASSWORD"],
    database: envConfig["DB_DATABASE"],
    entities: Entitys,
    // subscribers: Subscribers,
    migrations: ["migrations/*.ts"],
    synchronize: envConfig["DB_SYNC"] == "true",
    logging: process.env.NODE_ENV === "development",
};

export default new DataSource(ormConfig);
